import {type RouteRecordRaw, createRouter, createWebHashHistory} from "vue-router"

/**
 * 常驻路由
 * 除了 redirect/403/404/login 等隐藏页面，其他页面建议设置 Name 属性
 */
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/dashboard",
    meta: {
      title: "代理管理",
      elIcon: 'Files'
    },
    children: [
      {
        // 将匹配所有内容并将其放在 `$route.params.pathMatch` 下，打开文件就放在?open后面
        path: "/dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        name: "Dashboard",
        meta: {
          routerViewKey: '/dashboard',
          title: "浏览",
          svgIcon: "dashboard",
          activeMenu: '/dashboard',
          affix: true
        }
      },
    ]
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes
})

/** 重置路由 */
export function resetRouter() {
  window.location.reload()
}

export default router
